package com.example.flower_shop.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class CacheObject {
    /**
     * 数据 json
     */
    private String data;
    /**
     * 创建时间
     */
    private long createTime;
    /**
     * 过期时间 单位：秒 -1 表示不过期
     */
    private long expire;

    public CacheObject(String data) {
        this.data = data;
        this.createTime = System.currentTimeMillis();
        this.expire = -1;
    }

    public CacheObject(String data, long expire) {
        this.data = data;
        this.createTime = System.currentTimeMillis();
        this.expire = this.createTime + expire * 1000;
    }

}
